from aicoder_output import process_deepseek_text
from deepseek_python import load_init_files, chat_with_deepseek, save_session

# from rich.markdown import Markdown

OUTPUT_DIR = 'aicoder'
INIT_DIR ='aicoder_init'
SESSION_FILE_NAME = 'aicoder.pkl'

conversation_history = [
    # {"role": "system", "content": "你是一位编程高手，尤其擅长python"}
]

if __name__ == "__main__":
    print("DeepSeek 对话开始（输入'exit'退出）")
    load_init_files(INIT_DIR, conversation_history)

    # 可选：打印当前历史记录（调试用）
    print("\n[当前对话历史]")
    for msg in conversation_history:
        print(f"{msg['role']}:")
        print(f"{msg['content']}")
        print()

    while True:
        user_input = input("\nuser: ")

        if user_input.lower() in ['exit', 'quit']:
            print("对话结束")
            save_session(SESSION_FILE_NAME, conversation_history)
            break

        # 获取AI回复
        response = chat_with_deepseek(user_input, conversation_history)
        print(f"\nassistant:")
        print(f"{response}")
